package com.qn.example.mapper;

import com.qn.example.pojo.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 21276
 * @version 1.0
 * @date 2023/5/23 9:50
 */
public interface ShoppingCartMapper {

    ShoppingCart findByUserIdAndDishIdOrSetmeanId(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void save(ShoppingCart shoppingCart);

    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void update(ShoppingCart dbShoppingCart);

    @Select("select * from shopping_cart where user_id =#{userId}")
    List<ShoppingCart> findShoppingCarById(Long user);

    @Delete("delete from shopping_cart where user_id =#{userId}")
    void deleteByUserId(Long userId);



    ShoppingCart findByUserIdShoppingCart(@Param("dishId") Long dishId, @Param("setmealId")  Long setmealId, @Param("userId") Long userId);

    void delete(@Param("dishId") Long dishId,@Param("setmealId")  Long setmealId, @Param("userId") Long userId);

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> findShoppingCartByUserId(Long userId);
}
